package com.fundamental.classEx.classloader;

public class Test {

    public static volatile Func func = new Fun1();

    public static void main(String[] args){

        Thread thread = new Thread(()->{
            while (true){

                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                FuncLoader.reloadClass();
            }
        });

        //thread.start();
        while (true){
            synchronized (FuncLoader.class) {
                try {
                    //System.out.println(func);
                    FuncLoader.reloadClass();
                    func.doWhile();
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
